package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Text02 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("text2.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        Scanner scan = new Scanner(System.in);
        while (true){
            System.out.println("请输入：");
            String line = scan.nextLine();
            if ("exit".equalsIgnoreCase(line)) {
                break;
            }else {
                osw.write(line);
            }
        }
        osw.close();
    }
}
